package com.share.order.fallback;

import com.share.common.core.domain.Result;
import com.share.order.api.RemoteOrderInfoService;
import com.share.order.domain.OrderInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class RemoteOrderInfoFallback implements FallbackFactory<RemoteOrderInfoService> {

    @Override
    public RemoteOrderInfoService create(Throwable throwable) {

        log.error("订单服务调用失败:{}", throwable.getMessage());
        return new RemoteOrderInfoService() {
            @Override
            public Result<OrderInfo> getNoFinishOrder(Long userId) {
                return Result.fail("获取用户未完成订单失败:" + throwable.getMessage());
            }
        };
    }


}
